#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int maxmiumScore(vector<int>& cards, int cnt) {
    sort(cards.begin(), cards.end());
    int sum  = 0;
    int maxIndex = cards.size()-1;
    //最大的奇数
    int maxOdd = 1;
    //最大的偶数
    int maxEven = 0;
    while(cnt)
    {
        sum += cards[maxIndex--];
        //将cards中最后一个元素删除
        cards.pop_back();
        cnt--;
    }
    //寻找剩下的最后一个数使得总和为偶数
    if(sum%2==0)
    {
        return sum;
    }else
    {
        int minOdd = 0;
        //寻找最小的奇数
        for(int i=cards.size()-cnt;i>cards.size()-1;i++)
        {
            if(cards[i]%2==1)
            {
                minOdd = cards[i];
                break;
            }
        }
        for(int i=cards.size()-1-cnt;i>=0;i++)
        {
            if(cards[i]%2==0)
            {
                maxEven = cards[i];
                break;
            }
        }

    }
}
int main()
{
    int cnt;
    vector<int> cards(4);
    cout<<"Input the number of cards:"<<endl;
    for(int i=0;i<4;i++)
    {
        cin>>cards[i];
    }
    cout<<"Input the number of players:"<<endl;
    cin>>cnt;
    int sum = maxmiumScore(cards, cnt);
    cout<<"The maximum score is:"<<sum;
    return 0;
}